package sb.tiledui;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.wilson.android.library.DrawableManager;

public class TiledUIActivity extends Activity {
	/** Called when the activity is first created. */

	ArrayList<GroupPurchase> arryGP;
	LinearLayout llForSubTile;
	
	static boolean SUB_TILE_FRONT = true;
	static boolean SUB_TILE_BACK = false;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		//각종 뷰 초기화
		Display display = getWindowManager().getDefaultDisplay();
		Tile.DISPLAY_WIDTH = display.getWidth();
		llForSubTile = (LinearLayout) findViewById(R.id.ll_sub_tile);
		Paint pntForll = new Paint();
		pntForll.setColor(Color.BLACK);
		pntForll.setAlpha(150);
		llForSubTile.setBackgroundColor(pntForll.getColor());
		llForSubTile.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// 외부 클릭 시 subtile을 안보이게 한다.
			//	Log.i("SM","sub tile click out");
					changeView(SUB_TILE_BACK);
			}
		});
		RelativeLayout rlForSubTile = (RelativeLayout) findViewById(R.id.rl_sub_tile);
		rlForSubTile.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// 내부 클릭 시 화면 이동.
				Context context = v.getContext();
				Intent gpDetail = new Intent(context,
						GroupPurchaseDetail.class);
				
				TextView gpInformation = (TextView) findViewById(R.id.gp_information_sub_tile);
				String gpInfoStr =(String)gpInformation.getText();
				
				//Log.i("SM",gpInfoStr);
				gpDetail.putExtra("gp", gpInfoStr);
				
				context.startActivity(gpDetail);
			//	Log.i("SM","sub tile click in");
			}
		});
		RelativeLayout rl = (RelativeLayout) findViewById(R.id.rl);
		rl.setBackgroundColor(Color.BLACK);

		

		// arryGP 초기화
		arryGP = new ArrayList<GroupPurchase>();
		// 서버로부터 Group Purchase list를 받아온다.
		// 우선 startOffset과 endOffset은 모두 0으로 둔다. 실제 함수에선 쓰이진 않는다.
		getGroupPurchaseList(0, 0);
		int numberOfGP = arryGP.size();

		ArrayList<Tile> arry = new ArrayList<Tile>();
		// Tile 생성하고 정보 입력
		for (int i = 0; i < numberOfGP; i++) {
			Tile cv = new Tile(this);
			cv.parent = this;
			cv.gp = arryGP.get(i);

			// random하게 색 결정
			int colorSelectionNumber = (int) ((Math.random() * 100) % 6);
			switch (colorSelectionNumber) {
			case 0:
				// blue
				cv.color1 = Color.BLUE;
				cv.color2 = Color.parseColor("#00bfff");
				break;
			case 1:
				// green
				cv.color1 = Color.parseColor("#32cd32");
				cv.color2 = Color.parseColor("#e0ffff");
				break;
			case 2:
				// purple
				cv.color1 = Color.parseColor("#9400d3");
				cv.color2 = Color.parseColor("#dda0dd");
				break;
			case 3:
				// orange
				cv.color1 = Color.parseColor("#ff4500");
				cv.color2 = Color.parseColor("#ffb6c1");
				break;
			case 4:
				// yellow
				cv.color1 = Color.parseColor("#ffd700");
				cv.color2 = Color.parseColor("#ffffe0");
				break;
			case 5:
				// pink
				cv.color1 = Color.parseColor("#ff1493");
				cv.color2 = Color.parseColor("#dda0dd");
				break;
			}

			arry.add(cv);
		}

		// 각 Tile에 wieght를 입력한다.
		Tile cv = arry.get(0);
		int weightOfTile = Integer.valueOf(cv.gp.numberOfUsersWithDeposit)+Integer.valueOf(cv.gp.numberOfUsersWithoutDeposit);
		int maxWeight = weightOfTile;
		int minWeight = weightOfTile;
		cv.setWeight(weightOfTile);
		for (int i = 1; i < arry.size(); i++) {
			cv = arry.get(i);
			weightOfTile = Integer.valueOf(cv.gp.numberOfUsersWithDeposit)+Integer.valueOf(cv.gp.numberOfUsersWithoutDeposit);
			cv.setWeight(weightOfTile);
			if (weightOfTile > maxWeight)
				maxWeight = weightOfTile;
			if (weightOfTile < minWeight)
				minWeight = weightOfTile;
		}

		// Sorting by weight
		for (int i = 0; i < arry.size(); i++) {
			for (int j = i + 1; j < arry.size(); j++) {
				if (arry.get(i).weight < arry.get(j).weight) {
					Tile temp = arry.get(i);
					arry.set(i, arry.get(j));
					arry.set(j, temp);
				}
			}
		}

		// id assign
		for (int i = 0; i < arry.size(); i++) {
			arry.get(i).setId(i + 100); // id를 0부터 세팅 하면 이상하게 자꾸 id 0번을 갖는 Tile에
										// 이상이 생겨서 그냥 i+100 해준거임
		}

		int marginSize = 5;

		ArrayList<Tile> arry3 = new ArrayList<Tile>();
		ArrayList<Tile> arry2 = new ArrayList<Tile>();
		ArrayList<Tile> arry1 = new ArrayList<Tile>();

		// level assign
		int numOfBoxInOneLevel = numberOfGP / 4;
		for (int i = 0; i < numOfBoxInOneLevel; i++) {
			arry.get(i).level = 3;
			arry.get(i).calculateSizeOfView(marginSize);
			arry3.add(arry.get(i));
		}
		for (int i = numOfBoxInOneLevel; i < numOfBoxInOneLevel * 2; i++) {
			arry.get(i).level = 2;
			arry.get(i).calculateSizeOfView(marginSize);
			arry2.add(arry.get(i));
		}
		for (int i = numOfBoxInOneLevel * 2; i < arry.size(); i++) {
			arry.get(i).level = 1;
			arry.get(i).calculateSizeOfView(marginSize);
			arry1.add(arry.get(i));
		}

		Log.i("SM", "Begin");

		// LL에 넣어보자
		// 한 stage에 4개의 box가 들어간다
		// stageType에 따라서 4개의 박스가 어떤 형태로 들어가는지 결정된다.
		// StageSubType에 따라서 긴 박스가 가로로 들어갈지 세로로 들어갈지 결정된다.
		int numOfStage = (numberOfGP / Tile.NUM_OF_BOXES_IN_STAGE);
		int stageType = -1;
		int stageSubType = -1; // 0이면 세로 1이면 가로
		int prevStageType = -1;

		for (int i = 0; i < numOfStage; i++) {
			int topMargin = marginSize + i * (arry3.get(0).height + marginSize);
			while (prevStageType == stageType) {
				stageType = (int) ((Math.random() * 100) % 6);
			}
			stageSubType = (int) ((Math.random() * 100) % 2); // 0이면 세로 1이면 가로
			prevStageType = stageType;

			Tile box3 = arry3.get(i);
			Tile box2 = arry2.get(i);
			Tile box11 = arry1.get(2 * i);
			Tile box12 = arry1.get(2 * i + 1);

			RelativeLayout.LayoutParams lp3 = new RelativeLayout.LayoutParams(
					LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
			RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(
					LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
			RelativeLayout.LayoutParams lp11 = new RelativeLayout.LayoutParams(
					LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
			RelativeLayout.LayoutParams lp12 = new RelativeLayout.LayoutParams(
					LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

		//	Log.i("SM", "stageType : " + String.valueOf(stageType) + "\t subType : " + String.valueOf(stageSubType));
			switch (stageType) {
			case 0:
				lp3.leftMargin = marginSize;
				lp3.topMargin = topMargin;
				rl.addView(box3, lp3);

				if (stageSubType == 0) {
					lp2.addRule(RelativeLayout.RIGHT_OF, box3.getId());
					lp2.leftMargin = marginSize;
					lp2.topMargin = topMargin;
					rl.addView(box2, lp2);

					lp11.addRule(RelativeLayout.RIGHT_OF, box2.getId());
					lp11.leftMargin = marginSize;
					lp11.topMargin = topMargin;
					rl.addView(box11, lp11);

					lp12.addRule(RelativeLayout.RIGHT_OF, box2.getId());
					lp12.addRule(RelativeLayout.BELOW, box11.getId());
					lp12.leftMargin = marginSize;
					lp12.topMargin = marginSize;
					rl.addView(box12, lp12);
				} else {
					box2.width = box11.width * 2 + marginSize;
					box2.height = box11.height;
					lp2.addRule(RelativeLayout.RIGHT_OF, box3.getId());
					lp2.leftMargin = marginSize;
					lp2.topMargin = topMargin;
					rl.addView(box2, lp2);

					lp11.addRule(RelativeLayout.RIGHT_OF, box3.getId());
					lp11.addRule(RelativeLayout.BELOW, box2.getId());
					lp11.leftMargin = marginSize;
					lp11.topMargin = marginSize;
					rl.addView(box11, lp11);

					lp12.addRule(RelativeLayout.RIGHT_OF, box11.getId());
					lp12.addRule(RelativeLayout.BELOW, box2.getId());
					lp12.leftMargin = marginSize;
					lp12.topMargin = marginSize;
					rl.addView(box12, lp12);
				}

				break;
			case 1:
				lp3.leftMargin = marginSize;
				lp3.topMargin = topMargin;
				rl.addView(box3, lp3);

				if (stageSubType == 0) {

					lp11.addRule(RelativeLayout.RIGHT_OF, box3.getId());
					lp11.leftMargin = marginSize;
					lp11.topMargin = topMargin;
					rl.addView(box11, lp11);

					lp12.addRule(RelativeLayout.RIGHT_OF, box3.getId());
					lp12.addRule(RelativeLayout.BELOW, box11.getId());
					lp12.leftMargin = marginSize;
					lp12.topMargin = marginSize;
					rl.addView(box12, lp12);

					lp2.addRule(RelativeLayout.RIGHT_OF, box11.getId());
					lp2.leftMargin = marginSize;
					lp2.topMargin = topMargin;
					rl.addView(box2, lp2);
				} else {
					lp11.addRule(RelativeLayout.RIGHT_OF, box3.getId());
					lp11.leftMargin = marginSize;
					lp11.topMargin = topMargin;
					rl.addView(box11, lp11);

					lp12.addRule(RelativeLayout.RIGHT_OF, box11.getId());
					lp12.leftMargin = marginSize;
					lp12.topMargin = topMargin;
					rl.addView(box12, lp12);

					box2.width = box11.width * 2 + marginSize;
					box2.height = box11.height;
					lp2.addRule(RelativeLayout.RIGHT_OF, box3.getId());
					lp2.addRule(RelativeLayout.BELOW, box11.getId());
					lp2.leftMargin = marginSize;
					lp2.topMargin = marginSize;
					rl.addView(box2, lp2);
				}

				break;
			case 2:
				lp2.leftMargin = marginSize;
				lp2.topMargin = topMargin;
				rl.addView(box2, lp2);

				lp3.addRule(RelativeLayout.RIGHT_OF, box2.getId());
				lp3.leftMargin = marginSize;
				lp3.topMargin = topMargin;
				rl.addView(box3, lp3);

				lp12.addRule(RelativeLayout.RIGHT_OF, box3.getId());
				lp12.leftMargin = marginSize;
				lp12.topMargin = topMargin;
				rl.addView(box12, lp12);

				lp11.addRule(RelativeLayout.RIGHT_OF, box3.getId());
				lp11.addRule(RelativeLayout.BELOW, box12.getId());
				lp11.leftMargin = marginSize;
				lp11.topMargin = marginSize;
				rl.addView(box11, lp11);

				break;
			case 3:
				lp11.leftMargin = marginSize;
				lp11.topMargin = topMargin;
				rl.addView(box11, lp11);

				lp12.addRule(RelativeLayout.BELOW, box11.getId());
				lp12.leftMargin = marginSize;
				lp12.topMargin = marginSize;
				rl.addView(box12, lp12);

				lp3.addRule(RelativeLayout.RIGHT_OF, box11.getId());
				lp3.leftMargin = marginSize;
				lp3.topMargin = topMargin;
				rl.addView(box3, lp3);

				lp2.addRule(RelativeLayout.RIGHT_OF, box3.getId());
				lp2.leftMargin = marginSize;
				lp2.topMargin = topMargin;
				rl.addView(box2, lp2);
				break;
			case 4:
				if (stageSubType == 0) {
					lp2.leftMargin = marginSize;
					lp2.topMargin = topMargin;
					rl.addView(box2, lp2);

					lp11.addRule(RelativeLayout.RIGHT_OF, box2.getId());
					lp11.leftMargin = marginSize;
					lp11.topMargin = topMargin;
					rl.addView(box11, lp11);

					lp12.addRule(RelativeLayout.RIGHT_OF, box2.getId());
					lp12.addRule(RelativeLayout.BELOW, box11.getId());
					lp12.leftMargin = marginSize;
					lp12.topMargin = marginSize;
					rl.addView(box12, lp12);
				} else {
					box2.width = box11.width * 2 + marginSize;
					box2.height = box11.height;
					lp2.leftMargin = marginSize;
					lp2.topMargin = topMargin;
					rl.addView(box2, lp2);

					lp11.addRule(RelativeLayout.BELOW, box2.getId());
					lp11.leftMargin = marginSize;
					lp11.topMargin = marginSize;
					rl.addView(box11, lp11);

					lp12.addRule(RelativeLayout.BELOW, box2.getId());
					lp12.addRule(RelativeLayout.RIGHT_OF, box11.getId());
					lp12.leftMargin = marginSize;
					lp12.topMargin = marginSize;
					rl.addView(box12, lp12);
				}

				lp3.addRule(RelativeLayout.RIGHT_OF, box12.getId());
				lp3.leftMargin = marginSize;
				lp3.topMargin = topMargin;
				rl.addView(box3, lp3);

				break;
			case 5:
				if (stageSubType == 0) {
					lp11.leftMargin = marginSize;
					lp11.topMargin = topMargin;
					rl.addView(box11, lp11);

					lp12.addRule(RelativeLayout.BELOW, box11.getId());
					lp12.leftMargin = marginSize;
					lp12.topMargin = marginSize;
					rl.addView(box12, lp12);

					lp2.addRule(RelativeLayout.RIGHT_OF, box11.getId());
					lp2.leftMargin = marginSize;
					lp2.topMargin = topMargin;
					rl.addView(box2, lp2);
				} else {
					lp11.leftMargin = marginSize;
					lp11.topMargin = topMargin;
					rl.addView(box11, lp11);

					lp12.addRule(RelativeLayout.RIGHT_OF, box11.getId());
					lp12.leftMargin = marginSize;
					lp12.topMargin = topMargin;
					rl.addView(box12, lp12);

					lp2.addRule(RelativeLayout.BELOW, box11.getId());
					box2.width = box11.width * 2 + marginSize;
					box2.height = box11.height;
					lp2.leftMargin = marginSize;
					lp2.topMargin = marginSize;
					rl.addView(box2, lp2);
				}

				lp3.addRule(RelativeLayout.RIGHT_OF, box2.getId());
				lp3.leftMargin = marginSize;
				lp3.topMargin = topMargin;
				rl.addView(box3, lp3);

				break;
			}
		}
		// 한 stage에 4개의 박스가 들어가기 때문에 총 박스의 개수가 4의 배수가 아니면 3개 이하로 박스가 남게 된다.
		// 남은 박스의 사이즈는 가장 작은 사이즈이다.
		// 남은 박스에 대해서 차례로 배치한다.
		for (int j = 0, i = numOfStage * 2; i < arry1.size(); i++, j++) {
			int topMargin = marginSize + numOfStage
					* (arry3.get(0).height + marginSize);
			int leftMargin = marginSize + j * (arry1.get(0).width + marginSize);
			Tile box = arry1.get(i);
			RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
					LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
			lp.topMargin = topMargin;
			lp.leftMargin = leftMargin;
			rl.addView(box, lp);

		}

		arry.clear();
		for (int i = 0; i < arry3.size(); i++) {
			arry.add(arry3.get(i));
			arry.add(arry2.get(i));
			arry.add(arry1.get(2 * i));  
			arry.add(arry1.get(2 * i + 1));
		}
		for (int i = numOfStage * 2; i < arry1.size(); i++) {
			arry.add(arry1.get(i));
		}

		DrawableManager dm = new DrawableManager();
		for (int i = 0; i < arry.size(); i++) {
			dm.putImageUrlAndTile(arry.get(i).gp.imgUrl, arry.get(i));
		}
		dm.fetchDrawableOnThread();
		

	}

	public void makeNewRequestButtionClick(View v) {

		Intent makeNewRequestOfProduct = new Intent(this,
				MakeNewRequestOfProduct.class);
		startActivity(makeNewRequestOfProduct);
		/*String urlWithDeposit = "http://deprice4utest2.appspot.com/gp?action=djoin";
		String urlWithoutDeposit = "http://deprice4utest2.appspot.com/gp?action=njoin";
		
		for(int i=1;i<arryGP.size();i++){
			String key = arryGP.get(i).key;
			int numberOfJoin = (int) ((Math.random() * 100));
			for(int j=0;j<numberOfJoin;j++){
				int depositOrNot = (int) ((Math.random() * 100) % 2);
				String userId = null;
				String query = null;
				if(depositOrNot == 1){
					userId = "test_"+String.format("%03d", j);
					query = urlWithDeposit+"&itemkey="+key+"&userid="+userId;
				}else{
					userId = "test_"+String.format("%03d", j);
					query = urlWithoutDeposit+"&itemkey="+key+"&userid="+userId;
				}
				URL queryURL;
				try {
					queryURL = new URL(query);
					DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
					DocumentBuilder docBuilder;
					docBuilder = docBuilderFactory.newDocumentBuilder();
					Document doc = docBuilder.parse(queryURL.openStream());
				} catch (MalformedURLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}catch (ParserConfigurationException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}catch (SAXException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}*/
	}

	public void changeView(boolean subTileIsFront){
		changeView(subTileIsFront, null);
	}
	public void changeView(boolean subTileIsFront, GroupPurchase gp){
		if(subTileIsFront){
			this.llForSubTile.setVisibility(View.VISIBLE);
			
			ImageView imageView = (ImageView) findViewById(R.id.iv_sub_tile);
			DrawableManager dm = new DrawableManager();
			dm.fetchDrawableOnThread(gp.imgUrl, imageView);
			
			TextView tvForTitle = (TextView) findViewById(R.id.title_sub_tile);
			tvForTitle.setTextColor(Color.BLACK);
			int numberOfRequest = Integer.valueOf(gp.numberOfUsersWithDeposit)+Integer.valueOf(gp.numberOfUsersWithoutDeposit);
			String title = "("+String.valueOf(numberOfRequest)+")"+gp.title;
			tvForTitle.setText(title);
			
			TextView tvForDecription = (TextView) findViewById(R.id.description_sub_title);
			tvForDecription.setTextColor(Color.BLACK);
			tvForDecription.setText(gp.description);
			
			TextView gpInformation = (TextView) findViewById(R.id.gp_information_sub_tile);
			String gpInfoStr = gp.key+"%%"+gp.title+"%%"+gp.imgUrl+"%%"+gp.startUserId+"%%"+gp.lowestPrice+"%%"+gp.description+"%%"+gp.timeStart+"%%"+gp.timeEnd+"%%"+gp.numberOfUsersWithDeposit+"%%"+gp.numberOfUsersWithoutDeposit;
			gpInformation.setText(gpInfoStr);
		}else{
			llForSubTile.setVisibility(View.INVISIBLE);
			ImageView imageView = (ImageView) findViewById(R.id.iv_sub_tile);
			imageView.setImageBitmap(null);
		}
	}
	
	
	
	// 서버로부터 GroupPurchase list를 받아온다.
	public void getGroupPurchaseList(int startOffset, int endOffset) {
		String urlForGettingGroupPurchaseList = "http://deprice4utest2.appspot.com/gp?action=getlist";
		try {
			URL queryURL = new URL(urlForGettingGroupPurchaseList);
			DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
			DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
			Document doc = docBuilder.parse(queryURL.openStream());
			NodeList nodeList = doc.getElementsByTagName("gp");

			int totalItems = nodeList.getLength();
			Log.i("SM", "totalItems: " + totalItems);
			for (int i = 0; i < totalItems; ++i) {
				GroupPurchase gp = new GroupPurchase();
				Node node = nodeList.item(i);
				
				Element element = (Element)node;	
				gp.key = (String)(( (NodeList)( ( (Element)( (NodeList)element.getElementsByTagName("key") ).item(0) ).getChildNodes() ) ).item(0).getNodeValue());
				gp.title = (String)(( (NodeList)( ( (Element)( (NodeList)element.getElementsByTagName("title") ).item(0) ).getChildNodes() ) ).item(0).getNodeValue());
				gp.imgUrl = (String)(( (NodeList)( ( (Element)( (NodeList)element.getElementsByTagName("photo_url") ).item(0) ).getChildNodes() ) ).item(0).getNodeValue());
				gp.startUserId = (String)(( (NodeList)( ( (Element)( (NodeList)element.getElementsByTagName("start_userid") ).item(0) ).getChildNodes() ) ).item(0).getNodeValue());
				gp.lowestPrice = (String)(( (NodeList)( ( (Element)( (NodeList)element.getElementsByTagName("lprice") ).item(0) ).getChildNodes() ) ).item(0).getNodeValue());
				gp.description = (String)(( (NodeList)( ( (Element)( (NodeList)element.getElementsByTagName("description") ).item(0) ).getChildNodes() ) ).item(0).getNodeValue());
				gp.timeStart = (String)(( (NodeList)( ( (Element)( (NodeList)element.getElementsByTagName("time_start") ).item(0) ).getChildNodes() ) ).item(0).getNodeValue());
				gp.timeEnd = (String)(( (NodeList)( ( (Element)( (NodeList)element.getElementsByTagName("time_end") ).item(0) ).getChildNodes() ) ).item(0).getNodeValue());
				gp.numberOfUsersWithDeposit = (String)(( (NodeList)( ( (Element)( (NodeList)element.getElementsByTagName("deposit_userid_count") ).item(0) ).getChildNodes() ) ).item(0).getNodeValue());
				gp.numberOfUsersWithoutDeposit = (String)(( (NodeList)( ( (Element)( (NodeList)element.getElementsByTagName("nondeposit_userid_count") ).item(0) ).getChildNodes() ) ).item(0).getNodeValue());
				
				arryGP.add(gp);
				
				//String log = gp.key + "\t"+gp.title +"\t"+gp.imgUrl +"\t"+gp.startUserId +"\t"+gp.lowestPrice +"\t"+gp.description +"\t"+gp.timeStart+"\t"+gp.timeEnd +"\t"+gp.numberOfUsersWithDeposit +"\t"+gp.numberOfUsersWithoutDeposit +"\t";
				//Log.i("SM",log);
			}
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SAXException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ParserConfigurationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
